const sequelize = require("../db");
const response = require('../../utils/response');
const validate = require("../../utils/validate");
const { syncDatabaseRules } = require("../validations/settingValidation");

class SettingController {
    // 同步数据库
    async syncDatabase(ctx){
        try{
            let { password } = await validate(ctx, syncDatabaseRules);
            if(password != 'mySyncDatabasePassword') throw '密码错误'
            
            await sequelize.sync();
            response.success(ctx, null, '同步数据库成功');
        }catch(err){
            response.error(ctx, err);
        }
    }
}

module.exports = new SettingController();